﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp20
{
    class Program
    {
        private static Stream path;

        static void Main(string[] args)
        {
            FileStream fileStream = new FileStream(@"D:\\code\\test.txt", FileMode.Open, FileAccess.Write);



            BinaryWriter binaryWriter = new BinaryWriter(fileStream);

            binaryWriter.Write("祖安少年在线锤人");

            binaryWriter.Write("费用自理");

            binaryWriter.Write("1000块包月，10000包年");

            binaryWriter.Write("没办法奥 这个记事本不得行 没有UTF-8");

            binaryWriter.Flush();

            binaryWriter.Close();
            fileStream.Close();

            string path = @"D:\\code\\test.txt";

            StreamReader streamReader = new StreamReader(path);
            //判断文件中是否有字符
            while (streamReader.Peek() != -1)
            {
                string str = streamReader.ReadLine();
                Console.WriteLine(str);
            }
            streamReader.Close();
        }
    }
}
